/**
 * 
 */
package com.gosophia.conference.action.starting;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Scope;
import org.springframework.security.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import com.gosophia.commons.web.action.BaseSupportAction;
import com.gosophia.commons.web.logAnnotation.LogRecord;
import com.gosophia.conferenceManagement.common.ws.ConferenceHandleWebService;
import com.gosophia.conferenceManagement.scheme.dto.SchemeJobDataDTO;
import com.gosophia.conferenceManagement.starting.ws.ConferenceTransientStoreWebService;
import com.gosophia.oa.action.JudgeCurrentUndertaker;
import com.gosophia.springsecurity.UserDetailsImpl;
import com.gosophia.userManagement.dto.UserInfoDTO;
import com.opensymphony.xwork2.ActionContext;

/**
 * 功能：会议申请提交动作(submit)
 * 
 * @author tianchunyu
 * @since 2011-3-22 Copyright (c) 2010 Gosophia corporation All Rights Reserved
 */
@Controller("ConferenceStartingWithApplicationAction")
@Scope("prototype")
public class ConferenceStartingWithApplicationAction extends BaseSupportAction {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private SchemeJobDataDTO schemeJobDataDTO;
	public SchemeJobDataDTO getSchemeJobDataDTO() {
		return schemeJobDataDTO;
	}

	public void setSchemeJobDataDTO(SchemeJobDataDTO schemeJobDataDTO) {
		this.schemeJobDataDTO = schemeJobDataDTO;
	}

	@Autowired
	private ConferenceTransientStoreWebService conferenceTransientStoreWeService;
	@Autowired
	@Qualifier("conferenceHandleWebService")
	private ConferenceHandleWebService conferenceHandleWebService;
	@Autowired
	private JudgeCurrentUndertaker judgeCurrentUndertaker;
	
	@Override
	@LogRecord(eventAction="会议管理-提交会议申请",eventTarget="conferenceStartingDTO")
	public String _execute() throws Exception {
		// 得到当前用户
		UserDetailsImpl userDetails = (UserDetailsImpl) SecurityContextHolder
				.getContext().getAuthentication().getPrincipal();
		UserInfoDTO creatorDTO = userDetails.getUserAccountDTO().getUserInfoDTO();
		schemeJobDataDTO.setConferenceCreatorDTO(creatorDTO);
		
		// 调用申请发起的方法，发起会议申请
		SchemeJobDataDTO schemeJobDataDTOReturn  = conferenceHandleWebService.startingConferenceProcessing(schemeJobDataDTO);
		
		super.getRequestResult().setRsltCode("0");
		super.getRequestResult().setMessage(
				"名称为" + schemeJobDataDTOReturn.getConferenceName() + ", 任务编号为"
						+ schemeJobDataDTOReturn.getMissionCode() + "的会议发起成功");
		ActionContext.getContext().getSession().put("_lastOpResult",
				super.getRequestResult());

		if ("task".equals(this.getFromFlag())) {
			return "task";
		} else {
			return "business";
		}
	}

}
